﻿using System;
using MoonSharp.Interpreter;
using UnityEngine;

namespace Lua
{
	// Token: 0x020002ED RID: 749
	[MoonSharpUserData]
	public static class Event
	{
		// Token: 0x060011F9 RID: 4601 RVA: 0x00080A08 File Offset: 0x0007EC08
		public static void Send(string code, DynValue data)
		{
			EventManager.SendEvent(new IEvent
			{
				code = code,
				data = data
			});
		}

		// Token: 0x060011FA RID: 4602 RVA: 0x00080A30 File Offset: 0x0007EC30
		public static Listener Register(DynValue instance, string code, DynValue function)
		{
			if (function.Type != DataType.Function)
			{
				Debug.LogError("To Listen for events you must provide a function: Event.Listen(event, function)");
				return null;
			}
			return EventManager.Register(new LuaListener
			{
				instance = instance,
				function = function
			}, code);
		}

		// Token: 0x060011FB RID: 4603 RVA: 0x00080A70 File Offset: 0x0007EC70
		public static void Unregister(Listener listener)
		{
			EventManager.Unregister(listener);
		}
	}
}
